package org.example.springbootdemo02.mapper;



import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.springbootdemo02.dto.Page;
import org.example.springbootdemo02.pojo.Product;

import java.util.List;
import java.util.Map;

@Mapper
public interface ProductMapper {
    // 单条件查询
    @Select ("select * from product where id=#{id}")
    Product getById(Integer id);

    // 多条件模糊查询
    List<Product> getByCondition(Map<String, Object> params);

    // 查询全部
    @Select("select * from product")
    List<Product> getAll();

    // 新增
    int insert(Product product);

    // 批量新增
    int batchInsert(@Param ("list") List<Product> productList);

    // 更新
    int update(Product product);

    // 动态字段更新
    int dynamicUpdate(Map<String, Object> params);

    // 单个删除
    @Delete ("delete from product where id=#{id}")
    int delete(Integer id);

    // 批量删除
    int batchDelete(@Param ("ids") List<Integer> ids);

    // 条件删除
    int deleteByCondition(Map<String, Object> params);

    // 分页查询
    List<Product> getByPage(Page<Product> page);

    // 查询总数
    int count(Page<Product> page);
}
